<?php
session_start();
?>
<html>

<head>
<?php $a[0] = "active"; ?>
<?php
$idthe = $_POST['tbxMaThe'];
include ('head.php');

?>
</head>

<body>
<?php
include ('dbcon.php');
include ('webtitle.php');
include ('topbannermenu.php');
include ('leftmenu.php');
include ('rightmenu.php');

?>	
   
<div id = "divMid">
<div id="thongtinkh">
<?php
if(!isset($_SESSION['myname']))
	{
		echo 'Vui lòng đăng nhập .';
	}
	else
	{
		$a = mysql_fetch_array(mysql_query("select * from khachhang where id='".$_SESSION['myname']."'"));
		$aa = mysql_fetch_array(mysql_query("select * from user where username='".$_SESSION['myname']."'"));
		echo 'Xin chào '.$a[2];
		echo "<br><br>";
		$sql = mysql_query("select * from card where idthe = $idthe");
		if( mysql_num_rows($sql) == 1)
		{
			$b = mysql_fetch_array($sql);
			if ($b[2] == 0)
			{
				$tk = 0;
				$tk = $aa[3] + $b[1];
				mysql_query("update user set taikhoan = '$tk' where username = '".$_SESSION['myname']."'");
				mysql_query("update card set trangthai = 1 where idthe = '$idthe'");
				echo "<br><br>Nạp Thẻ Thành công.";
				$aaa = mysql_fetch_array(mysql_query("select * from user where username='".$_SESSION['myname']."'"));
				
				echo "<br><br>Số tiền hiện tại là : $aaa[3] đ";
				
				
			}		
			else
			echo "<br><br> mã thẻ đã được sử dụng rồi !!!";
		}
		else
		echo "<br><br>Mã thẻ sai !!! Xin vui lòng kiểm tra lại !";
		
		

	}
?>	
</div></div>
		<div class="clr"></div>
		<?php 
		include ('footer.php');
		?>
</div>
</body>
</html>